Before removing outliers
ggplot(d, aes(ReactionTime, fill=Task)) +
geom_density(alpha = .5)
summary(d$ReactionTime)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 147 764 956 1105 1245 11219
Long tail justifies outlier removal?
ggplot(d, aes(LogReactionTime, fill=Task)) +
geom_density(alpha = .5)
summary(d$LogReactionTime)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.990 6.639 6.863 6.912 7.127 9.325
agr = d %>%
group_by(Task,LogReactionTime) %>%
summarize(MeanAccuracy = mean(Accuracy) )
## `summarise()` has grouped output by 'Task'. You can override using the
## `.groups` argument.
ggplot(agr, aes(x = MeanAccuracy, y = LogReactionTime, fill = MeanAccuracy)) +
geom_boxplot(alpha = 0.7) + # Boxplot
geom_jitter(position = position_jitter(0.2), color = "black", size = 1.5, alpha = 0.5) + # Add jittered points
facet_wrap(~Task) +
labs(title = "Reaction Time by Accuracy",
x = "Accuracy",
y = "Reaction Time (ms)") +
theme(legend.position = "none") # Remove legend
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?
## Warning: The following aesthetics were dropped during statistical transformation: fill.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
## The following aesthetics were dropped during statistical transformation: fill.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
ggplot(d, aes(x = Accuracy, y = LogReactionTime, fill = Task)) +
geom_violin(alpha = 0.7) + # Violin plot
geom_jitter(position = position_jitter(0.2), color = "black", size = 1.5, alpha = 0.5) + # Add jittered points
labs(title = "Reaction Time by Accuracy",
x = "Accuracy",
y = "Reaction Time (ms)")
# theme(legend.position = "none") # Remove legend
agr <- d %>%
group_by(Task) %>%
reframe(MeanAccuracy = mean(Accuracy),
CILow = ci.low(Accuracy),
CIHigh = ci.high(Accuracy)) %>%
mutate(YMin = MeanAccuracy - CILow,
YMax = MeanAccuracy + CIHigh)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=Task,y=MeanAccuracy,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9))
agr <- d %>%
group_by(Task,Word) %>%
mutate(MeanAccuracy = mean(Accuracy),
CILow = ci.low(Accuracy),
CIHigh = ci.high(Accuracy)) %>%
mutate(YMin = MeanAccuracy - CILow,
YMax = MeanAccuracy + CIHigh)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=Word,y=MeanAccuracy,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# guides(fill = "none")
agr <- d %>%
group_by(Task,ID.true) %>%
mutate(MeanAccuracy = mean(Accuracy),
CILow = ci.low(Accuracy),
CIHigh = ci.high(Accuracy)) %>%
mutate(YMin = MeanAccuracy - CILow,
YMax = MeanAccuracy + CIHigh)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=ID.true,y=MeanAccuracy,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
length(unique(d$ID.true))
## [1] 40
inacc.parts <- d %>%
group_by(Task,ID.true) %>%
summarise(MeanAccuracy = mean(Accuracy)) %>%
filter(MeanAccuracy < .75)
## `summarise()` has grouped output by 'Task'. You can override using the
## `.groups` argument.
# How many participants have accuracy < .75?
length(unique(inacc.parts$ID.true))
## [1] 6
d.inaccurate.removed <- d %>%
anti_join(inacc.parts, by = "ID.true")
# Sanity check
length(unique(d.inaccurate.removed$ID.true))
## [1] 34
agr <- d.inaccurate.removed %>%
group_by(Task) %>%
reframe(MeanAccuracy = mean(Accuracy),
CILow = ci.low(Accuracy),
CIHigh = ci.high(Accuracy)) %>%
mutate(YMin = MeanAccuracy - CILow,
YMax = MeanAccuracy + CIHigh)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=Task,y=MeanAccuracy,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9))
agr <- d.inaccurate.removed %>%
group_by(Task,Word) %>%
mutate(MeanAccuracy = mean(Accuracy),
CILow = ci.low(Accuracy),
CIHigh = ci.high(Accuracy)) %>%
mutate(YMin = MeanAccuracy - CILow,
YMax = MeanAccuracy + CIHigh)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=Word,y=MeanAccuracy,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
agr <- d.inaccurate.removed %>%
group_by(Task,ID.true) %>%
mutate(MeanAccuracy = mean(Accuracy),
CILow = ci.low(Accuracy),
CIHigh = ci.high(Accuracy)) %>%
mutate(YMin = MeanAccuracy - CILow,
YMax = MeanAccuracy + CIHigh)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=ID.true,y=MeanAccuracy,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# Remove subjects with ReactionTime higher than 3x IQR
summary(d.inaccurate.removed$LogReactionTime)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.990 6.605 6.830 6.882 7.093 9.325
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 6.924 7.328 7.436 7.479 7.579 10.008
range(d.inaccurate.removed$LogReactionTime)
## [1] 4.990433 9.325364
hist(d.inaccurate.removed$LogReactionTime, breaks=100, col="lightblue", xlab="LogReactionTime (ms)",
main="Histogram with Normal Curve")
quantile(d.inaccurate.removed$LogReactionTime)
## 0% 25% 50% 75% 100%
## 4.990433 6.605298 6.830334 7.093405 9.325364
IQR(d.inaccurate.removed$LogReactionTime)*3 # 0.7526289
## [1] 1.46432
cutoff.high <- quantile(d.inaccurate.removed$LogReactionTime)[4] + IQR(d.inaccurate.removed$LogReactionTime)*3 # 8.419261
cutoff.low <- quantile(d.inaccurate.removed$LogReactionTime)[2] - IQR(d.inaccurate.removed$LogReactionTime)*3# 6.5088838.419261
# remove subjects with ReactionTime higher than 3 x IQR
df.outliers.removed <- subset(d.inaccurate.removed, (d.inaccurate.removed$LogReactionTime > cutoff.low) & (d.inaccurate.removed$LogReactionTime < cutoff.high))
hist(df.outliers.removed$LogReactionTime, col="lightblue", xlab="LogReactionTime (ms)",
main="Histogram with Normal Curve")
agr = df.outliers.removed %>%
group_by(Task, LogReactionTime) %>%
summarize(MeanAccuracy = mean(Accuracy))
## `summarise()` has grouped output by 'Task'. You can override using the
## `.groups` argument.
ggplot(agr, aes(x = MeanAccuracy, y = LogReactionTime, fill = MeanAccuracy)) +
geom_boxplot(alpha = 0.7) + # Boxplot
geom_jitter(position = position_jitter(0.2), color = "black", size = 1.5, alpha = 0.5) + # Add jittered points
facet_wrap(~Task) +
labs(title = "Reaction Time by Accuracy",
x = "Accuracy",
y = "Reaction Time (ms)") +
theme(legend.position = "none") # Remove legend
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?
## Warning: The following aesthetics were dropped during statistical transformation: fill.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
## The following aesthetics were dropped during statistical transformation: fill.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
ggplot(df.outliers.removed, aes(x = Accuracy, y = LogReactionTime, fill = Task)) +
geom_violin(alpha = 0.7) + # Violin plot
geom_jitter(position = position_jitter(0.2), color = "black", size = 1.5, alpha = 0.5) + # Add jittered points
labs(title = "Reaction Time by Accuracy",
x = "Accuracy",
y = "Reaction Time (ms)")
agr <- df.outliers.removed %>%
group_by(Task) %>%
reframe(MeanAccuracy = mean(Accuracy),
CILow = ci.low(Accuracy),
CIHigh = ci.high(Accuracy)) %>%
mutate(YMin = MeanAccuracy - CILow,
YMax = MeanAccuracy + CIHigh)
# View(agr)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=Task,y=MeanAccuracy,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9))
# theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
# guides(fill = "none")
agr <- df.outliers.removed %>%
# filter(PennElementType == "Selector") %>%
# select(ID.true,Word,Accuracy) %>%
group_by(Task,Word) %>%
mutate(MeanAccuracy = mean(Accuracy),
CILow = ci.low(Accuracy),
CIHigh = ci.high(Accuracy)) %>%
mutate(YMin = MeanAccuracy - CILow,
YMax = MeanAccuracy + CIHigh)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=Word,y=MeanAccuracy,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
guides(fill = "none")
# View(d[(d$ID.true == c("56cc78e3ccc0e20006b82a7d")) & (d$Word == c("envy")),])
agr = df.outliers.removed %>%
group_by(Task,Word) %>%
summarize(MeanReactionTime = mean(ReactionTime),
CILow = ci.low(ReactionTime),
CIHigh = ci.high(ReactionTime)) %>%
mutate(YMin = MeanReactionTime - CILow,
YMax = MeanReactionTime + CIHigh)
## `summarise()` has grouped output by 'Task'. You can override using the
## `.groups` argument.
ggplot(agr, aes(x=MeanReactionTime, fill=Task)) +
geom_density(alpha = .4)
ggplot(agr, aes(x=Task, y=MeanReactionTime,fill=Task)) +
geom_violin(trim=FALSE,alpha=.4) +
geom_jitter(position = position_jitter(0.2), color = "black", size = 1.5, alpha = 0.5) # Add jittered points
# guides(fill = "none")
agr = df.outliers.removed %>%
group_by(Task,Word) %>%
summarize(MeanReactionTime = mean(ReactionTime), CILow = ci.low(ReactionTime), CIHigh = ci.high(ReactionTime)) %>%
mutate(YMin = MeanReactionTime - CILow, YMax = MeanReactionTime + CIHigh)
## `summarise()` has grouped output by 'Task'. You can override using the
## `.groups` argument.
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=Word,y=MeanReactionTime,fill=Task)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# guides(fill = "none")
agr = df.outliers.removed %>%
group_by(Task,ConcValCombo) %>%
reframe(MeanReactionTime = mean(ReactionTime), CILow = ci.low(ReactionTime), CIHigh = ci.high(ReactionTime)) %>%
mutate(YMin = MeanReactionTime - CILow, YMax = MeanReactionTime + CIHigh)
dodge = position_dodge(.9)
ggplot(data=agr, aes(x=Task,y=MeanReactionTime,fill=ConcValCombo)) +
geom_bar(position=dodge,stat="identity") +
geom_errorbar(aes(ymin=YMin,ymax=YMax),width=.25,position=position_dodge(0.9)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# guides(fill = "none")